const Mock = require('mockjs')

const FixitemList=[];
for(let i=0;i<100;i++){
    FixitemList.push(
        Mock.mock({
            id:'@increment',
            itemname:'@integer(10000,99999)',
            worktime:'@integer(1,30)',
            price:'@integer(4,100)',
            worktimeprice:'@integer(4,100)',
            keepfit:'@integer(0,1)',
            state:'@integer(0,1)',
            worktype:'@first',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

const ExtraitemList=[];
for(let i=0;i<100;i++){
    ExtraitemList.push(
        Mock.mock({
            id:'@increment',
            itemname:'@integer(10000,99999)',
            state:'@integer(0,1)',
            worktype:'@first',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

const FixcategoryList=[];
for(let i=0;i<100;i++){
    FixcategoryList.push(
        Mock.mock({
            id:'@increment',
            itemname:'@integer(10000,99999)',
            state:'@integer(0,1)',
            fixtype:'@first',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

const WorktypeList=[];
for(let i=0;i<100;i++){
    WorktypeList.push(
        Mock.mock({
            id:'@increment',
            itemname:'@integer(10000,99999)',
            state:'@integer(0,1)',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

const WorkshopList=[];
for(let i=0;i<100;i++){
    WorkshopList.push(
        Mock.mock({
            id:'@increment',
            itemname:'@integer(10000,99999)',
            state:'@integer(0,1)',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

const WorkgroupList=[];
for(let i=0;i<100;i++){
    WorkgroupList.push(
        Mock.mock({
            id:'@increment',
            itemname:'@integer(10000,99999)',
            groupleader:'@first',
            workshop:'@integer(11111,99999)',
            worktype:'@integer(111,9999)',
            taskmonth:'@integer(100000,999999)',
            state:'@integer(0,1)',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

const WorktimeList=[];
for(let i=0;i<100;i++){
    WorktimeList.push(
        Mock.mock({
            id:'@increment',
            itemname:'@integer(10000,99999)',
            reach:'@integer(0,100)',
            rate:'@integer(0,50)',
            state:'@integer(0,1)',
            remark:'@remark',
            createtime:'@datetime',
        })
    )
}

module.exports=[
    {
        url: '/api/aftersale/fixitem',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = FixitemList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/aftersale/extraitem',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = ExtraitemList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/aftersale/fixcategory',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = FixcategoryList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/aftersale/worktype',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = WorktypeList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/aftersale/workshop',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = WorkshopList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/aftersale/worktime',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = WorktimeList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/aftersale/workgroup',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = WorkgroupList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
]